package com.deryun.tyl.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.deryun.tyl.bean.News;
import com.deryun.tyl.service.impl.NewsServiceImpl;

@Controller
@RequestMapping("news")
public class NewsController {
	
	@Resource(name = "newsServiceImpl")
	private NewsServiceImpl newsServiceImpl;
	
	@RequestMapping("/getAllNews")
	public List<News> getAllNews(){
		return newsServiceImpl.getAllNews();
	}
	
	/***
	 * 添加行业动态
	 * @param news
	 * @return 返回页面路径
	 */
	@RequestMapping("/addNews")
	public String addNews(News news){
		int result = newsServiceImpl.addNews(news);
		if (result == 1) {
			return "redirect:/ftoac/toLoadZtxw";//添加成功后返回的页面
		}
		return "back_admin_manger/toLoad_add";//添加失败后返回的页面
	}
	
	/***
	 * 删除行业动态
	 * @param id
	 * @return 返回页面路径
	 */
	@RequestMapping("/deleteNews")
	public String deleteNews(int id){
		int result = newsServiceImpl.deleteNews(id);
		if (result == 1) {
			return "redirect:/ftoac/toLoadZtxw";//删除成功后返回的页面
		}
		return "false";//删除失败后返回的页面
	}
}
